package orders

import (
	"api/internal/svc"
	"api/internal/types"
	"context"
	"order_srv/orderclient"

	"github.com/zeromicro/go-zero/core/logx"
)

type GetAfterSaleLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewGetAfterSaleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAfterSaleLogic {
	return &GetAfterSaleLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *GetAfterSaleLogic) GetAfterSale(req *types.GetAfterSaleRequest) (resp *types.Response, err error) {
	afterSale, err := l.svcCtx.OrderRpc.GetAfterSale(l.ctx, &orderclient.GetAfterSaleRequest{
		AfterSaleId: req.AfterSaleId,
	})
	if err != nil {
		return &types.Response{
			Code:    400,
			Message: err.Error(),
		}, nil
	}
	return &types.Response{
		Code:    200,
		Message: "查询售后成功",
		Data:    afterSale,
	}, nil
}
